package com.xiaoai.httpClientTestService.httpclient.one;

import org.apache.hc.client5.http.async.HttpAsyncClient;
import org.apache.hc.client5.http.async.methods.SimpleBody;
import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
import org.apache.hc.client5.http.async.methods.SimpleHttpRequests;
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.ParseException;
import org.apache.hc.core5.http.io.entity.EntityUtils;

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * 连接池
 */
public class HttpclientDemo3 {
    
    public static void main(String[] args) throws IOException, ParseException, ExecutionException, InterruptedException {

        CloseableHttpAsyncClient aDefault = HttpAsyncClients.createDefault();

        SimpleHttpRequest request = SimpleHttpRequests.get("http://www.baidu.com");

        Future<SimpleHttpResponse> future = aDefault.execute(request, null);

        SimpleHttpResponse simpleHttpResponse = future.get();

        simpleHttpResponse.getBodyText();

        SimpleBody body = simpleHttpResponse.getBody();

        System.out.println(body.getBodyText());


    }
    
    
}
